package com.datastructures2.graph.最短路径;

import edu.princeton.cs.algs4.BellmanFordSP;

/**
 * 任意顶点对之间的最短路径
 * @author MaoLin Wang
 * @date 2020/2/2413:20
 */
public class DijkstraAllPairsSP {
    private DijkstraSP[]all;


    public DijkstraAllPairsSP(EdgeWeightedDigraph digraph){
        all=new DijkstraSP[digraph.V()];
        for (int i = 0; i < digraph.V(); i++) {
            all[i]=new DijkstraSP(digraph,i);
        }
    }

    public Iterable<DirectedEdge> path(int s,int t){
        return all[s].pathTo(t);
    }
    public double distBetween(int s,int t){
        return all[s].distTo(t);
    }
}
